<?php
ob_start();
session_start();

$id=$_SESSION['id'];

  include_once('restconnection.php'); 
     
     if(isset($client)){  
         
        //Applause RATE
        //retrive base url 
        $url = $_SESSION['basic_url'];
        //add service url
        $service_url="/ApplauseRate?";
        //params url
        $params = array('id'=>$id); 
        //params connection
        $ctx = stream_context_create(array('http' => array('timeout' => 5))); 
        //send GET request
        $final_url = $url.$service_url."id=".$params['id'];
        //print_r($final_url); break;
        $output = @file_get_contents($final_url,0,$ctx);
        //parse JSON output
        //print_r($url.$service_url."id=".$params['id']); break;
        $data = json_decode($output);
        //var_dump($output); break;
        $applauseRate =$data->ApplauseRateResult;
        //print_r($applauseRate); break;
        
        //Conversation RATE   
        $service_url="/ConversationRate?";
        //params url
        $params = array('id'=>$id); 
        //params connection
        $ctx = stream_context_create(array('http' => array('timeout' => 5))); 
        //send GET request
        $final_url = $url.$service_url."id=".$params['id'];
        //print_r($final_url); break;
        $output = @file_get_contents($final_url,0,$ctx);
        //parse JSON output
        //print_r($url.$service_url."id=".$params['id']); break;
        $data = json_decode($output);
        //var_dump($output); break;
        $conversationRate = $data->ConversationRateResult;
        
        
        //Amplification RATE
        $service_url="/AmplificationRate?";
        //params url
        $params = array('id'=>$id); 
        //params connection
        $ctx = stream_context_create(array('http' => array('timeout' => 5))); 
        //send GET request
        $final_url = $url.$service_url."id=".$params['id'];
        //print_r($final_url); break;
        $output = @file_get_contents($final_url,0,$ctx);
        //parse JSON output
        //print_r($url.$service_url."id=".$params['id']); break;
        $data = json_decode($output);
        //var_dump($output); break;
        $amplificationRate = $data->AmplificationRateResult;
        
        //Applause rate Facebook
        $service_url="/ApplauseRateFB?";
        //params url
        $params = array('id'=>$id); 
        //params connection
        $ctx = stream_context_create(array('http' => array('timeout' => 5))); 
        //send GET request
        $final_url = $url.$service_url."id=".$params['id'];
        //print_r($final_url); break;
        $output = @file_get_contents($final_url,0,$ctx);
        //parse JSON output
        //print_r($url.$service_url."id=".$params['id']); break;
        $data = json_decode($output);
        //var_dump($output); break;
        $applauseRatefb =$data->ApplauseRateFBResult;
        
        //Applause rate Google    
        $service_url="/ApplauseRateGO?";
        //params url
        $params = array('id'=>$id); 
        //params connection
        $ctx = stream_context_create(array('http' => array('timeout' => 5))); 
        //send GET request
        $final_url = $url.$service_url."id=".$params['id'];
        //print_r($final_url); break;
        $output = @file_get_contents($final_url,0,$ctx);
        //parse JSON output
        //print_r($url.$service_url."id=".$params['id']); break;
        $data = json_decode($output);
        //var_dump($output); break;
        $applauseRatego =$data->ApplauseRateGOResult;
        
        
         //Conversation rate Facebook
        $service_url="/ConversationRateFB?";
        //params url
        $params = array('id'=>$id); 
        //params connection
        $ctx = stream_context_create(array('http' => array('timeout' => 5))); 
        //send GET request
        $final_url = $url.$service_url."id=".$params['id'];
        //print_r($final_url); break;
        $output = @file_get_contents($final_url,0,$ctx);
        //parse JSON output
        //print_r($url.$service_url."id=".$params['id']); break;
        $data = json_decode($output);
        //var_dump($output); break;
        $conversationRatefb =$data->ConversationRateFBResult;
        
        //Conversation rate Google    
        $service_url="/ConversationRateGO?";
        //params url
        $params = array('id'=>$id); 
        //params connection
        $ctx = stream_context_create(array('http' => array('timeout' => 5))); 
        //send GET request
        $final_url = $url.$service_url."id=".$params['id'];
        //print_r($final_url); break;
        $output = @file_get_contents($final_url,0,$ctx);
        //parse JSON output
        //print_r($url.$service_url."id=".$params['id']); break;
        $data = json_decode($output);
        //var_dump($output); break;
        $conversationRatego =$data->ConversationRateGOResult;
        
        
        //Amplification rate Twitter
        $service_url="/AmplificationRateTW?";
        //params url
        $params = array('id'=>$id); 
        //params connection
        $ctx = stream_context_create(array('http' => array('timeout' => 5))); 
        //send GET request
        $final_url = $url.$service_url."id=".$params['id'];
        //print_r($final_url); break;
        $output = @file_get_contents($final_url,0,$ctx);
        //parse JSON output
        //print_r($url.$service_url."id=".$params['id']); break;
        $data = json_decode($output);
        //var_dump($output); break;
        $amplificationRatetw =$data->AmplificationRateTWResult;
        
        //Amplification rate Google    
        $service_url="/AmplificationRateGO?";
        //params url
        $params = array('id'=>$id); 
        //params connection
        $ctx = stream_context_create(array('http' => array('timeout' => 5))); 
        //send GET request
        $final_url = $url.$service_url."id=".$params['id'];
        //print_r($final_url); break;
        $output = @file_get_contents($final_url,0,$ctx);
        //parse JSON output
        //print_r($url.$service_url."id=".$params['id']); break;
        $data = json_decode($output);
        //var_dump($output); break;
        $amplificationRatego =$data->AmplificationRateGOResult;
?>

<head>
    <title>General stats</title>
    <link rel="stylesheet" type="text/css" href="css/table_css.css">
</head>

<body style="background-color: white; text-align: center;"
<label>STATISTIC FOR YOUR CONNECTED SOCIAL NETWORK!</label>
<br /><br />

<strong><label>Panoramic view </label></strong><a href="interaction.php" ><label>| Interaction </label></a> <a href="engagement.php" ><label>| Engagement </label></a> <a href="passion.php" ><label>| Passion </label></a>

<br/> <br/> 

<label style="font-size: 30px; ">Panoramic view</label>

<br /><br /><br />

<?php 
 
$targetUrl = "applause_rate_graph.php?1=". round($applauseRatefb,2) . "&2=". round($applauseRatego,2); 

//print_r($targetUrl);
 
echo "<img src='$targetUrl'>";  

?>

<?php 
 
$targetUrl = "conversation_rate_graph.php?1=". round($conversationRatefb,2) . "&2=". round($conversationRatego,2); 
 
echo "<img src='$targetUrl'>";  

?>

<?php 
 
$targetUrl = "amplification_rate_graph.php?1=". round($amplificationRatetw,2) . "&2=". round($amplificationRatego,2); 

//print_r($targetUrl);
 
echo "<img src='$targetUrl'>";  

?>

<br/> 

<label> MORE DETAILS</label>

<br/> 


    
<div class="CSSTableGenerator" >
<table width="100%" border="1" cellpadding="10" cellspacing="1">
    <tr>
        <td>Metrics</td>
        <td>Facebook</td>
        <td>Twitter</td>
        <td>Google+</td>
        <td title="Total average from social networks">Aggregate</td>
        
    </tr>

<?php
 
 
   
        
        
        
       
        ?>          <tr> 
                    <td title="Average of the likes received for each post;The formulas is # of total likes divided by # of total posts">
                        <strong>Applause Rate?</strong>
                    </td>
                    <td><?php echo round($applauseRatefb,2); ?></td>
                    <td><?php echo"Not Calculable!";  ?></td>
                    <td><?php echo round($applauseRatego,2); ?></td> 
                    <td title="Aggregate Facebook and Google+"><?php echo round($applauseRate,2); ?></td> 
                    </tr>
                    
                    <tr> 
                    <td title="Average of the comments received for each post;The formulas is # of total comments divided by # of total posts"><strong>Conversation Rate?</strong></td>
                    <td><?php echo round($conversationRatefb,2); ?></td>
                    <td><?php echo"Not Calculable!"; ?></td>
                    <td><?php echo round($conversationRatego,2); ?></td> 
                    <td title="Aggregate Facebook and Google+"><?php echo round($conversationRate,2); ?></td> 
                    </tr>
                    
                    <tr> 
                    <td title="Average of the shares received for each post;The formulas is # of total shares divided by # of total posts"><strong>Amplification Rate?</strong></td>
                    <td><?php echo"Not Calculable!"; ?></td>
                    <td><?php echo round($amplificationRatetw,2); ?></td>
                    <td><?php echo round($amplificationRatego,2); ?></td> 
                    <td title="Aggregate Twitter and Google+"><?php echo round($amplificationRate,2); ?></td> 
                    </tr>
        <?php
                  
                             
          }else{
              ?>
              <label style="margin-left:0px;">There are no posts</label>
            
              <?php  
          }
              
   
             
        ?>    

 
</table>
</div>    
</body>

